﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Portal.GUI.EditoralOffice.MainOffce.LogNewsList
{
    public partial class LogNewsList : Portal.API.Module
    {
        #region Page Load
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                String param = Request.QueryString["NewsRef"];
                //String strNewsID = "200812144337375";
                
                odsLogNews.SelectParameters["News_ID"].DefaultValue = param;
             //   btnBack.CommandArgument = param[1].ToString();
                gvDataAction.DataBind();
            }
        }
        #endregion
        #region Data bound
        protected void gvDataAction_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //e.Row.
        }
        #endregion
        #region Check Thoi Gian
        public string CheckDateTime(String datetime)
        {
            if (datetime.Equals(String.Empty))
            {
                return String.Empty;
            }
            else
            {
                return Convert.ToDateTime(datetime).ToString("dd/MM/yyyy hh:mm:ss tt");
            }

        }
        #endregion
        #region Hoi Phuc Tin
        protected void btnHoiPhucTin_Click(object sender, EventArgs e)
        {
            String query = Request.Form["restore"];
            if (query == null || query.Equals( String.Empty)) { return; }

            Portal.Core.DAL.Log_News logNews = new Portal.Core.DAL.Log_News();
            Portal.BO.Editoral.LogNews.LogHelper logHelper = new Portal.BO.Editoral.LogNews.LogHelper();
            logNews = logHelper.SelectOneLogNewsObject(Convert.ToInt64(query));

            logHelper.UpdateNews(logNews);
            if (logNews.News_Status == 3)
            {
                logHelper.UpdateNewsPublished(logNews);
            }
            Page.RegisterStartupScript("", "<script language='javascript'>alert('Bạn đã hồi phục tin thành công')</script>");

        }
        #endregion
        #region Quay lai
        protected void btnQuayLai_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/office/" + hfCpmode.Value + ".chn");
        }
        #endregion
    }
}